Current Location: Home> Function Categories> base_convert

base_convert

Convert numbers between any binary
Name:base_convert
Category:math
Programming Language:php
One-line Description:Convert numbers between any bit.

Definition and usage

base_convert() function converts numbers between arbitrary bits.

Example

Example 1

Convert hexadecimal numbers to octal numbers:

 <?php
$hex = "E196" ;
echo base_convert ( $hex , 16 , 8 ) ;
?>

Try it yourself

Example 2

Convert octal numbers to decimal numbers:

 <?php
$oct = "0031" ;
$dec = base_convert ( $oct , 8 , 10 ) ;
echo "The octal $oct is equal to the decimal $dec ." ;
?>

Try it yourself

Example 3

Convert octal numbers to hexadecimal numbers:

 <?php
$oct = "364" ;
$hex = base_convert ( $oct , 8 , 16 ) ;
echo "The octal $oct is equal to the hex $hex ." ;
?>

Try it yourself

grammar

 base_convert ( number , frombase , tobase )
parameter describe
number Required. Original value.
frombase Required. The original number of the digital.
tobase Required. The binary to be converted.

illustrate

Returns a string containing the number expressed in tobase . The number itself's binary system is specified by frombase . Both frombase and tobase can only be between 2 and 36 (including 2 and 36). Numbers higher than decimal are represented by the letter az, for example a means 10, b means 11 and z means 35.

Similar Functions
  • Convert hexadecimal to decimal hexdec

    hexdec

    Converthexadecimalto
  • Calculate the oblique length of a straight triangle hypot

    hypot

    Calculatetheobliquel
  • Antihyperbolic cosine acosh

    acosh

    Antihyperboliccosine
  • Convert radians to corresponding angles rad2deg

    rad2deg

    Convertradianstocorr
  • Find the minimum value min

    min

    Findtheminimumvalue
  • Calculate the index of e exp

    exp

    Calculatetheindexofe
  • Round the division result intdiv

    intdiv

    Roundthedivisionresu
  • Display the maximum possible value of a random number mt_getrandmax

    mt_getrandmax

    Displaythemaximumpos
Popular Articles